package com.zenithmind.gateway.auth;

import java.util.Map;

/**
 * 用户信息解析器接口
 * 遵循接口隔离原则：专门负责从token中解析用户信息
 * 遵循单一职责原则：只负责用户信息的解析逻辑
 */
public interface UserInfoParser {
    
    /**
     * 从token中解析用户信息
     * @param token JWT token
     * @return 用户信息，包含用户ID、角色等
     * @throws Exception 解析失败时抛出异常
     */
    UserInfo parseUserInfo(String token) throws Exception;
    
    /**
     * 用户信息数据类
     */
    class UserInfo {
        private final String userId;
        private final String userRoles;
        private final Map<String, Object> claims;
        
        public UserInfo(String userId, String userRoles, Map<String, Object> claims) {
            this.userId = userId;
            this.userRoles = userRoles;
            this.claims = claims;
        }
        
        public String getUserId() {
            return userId;
        }
        
        public String getUserRoles() {
            return userRoles;
        }
        
        public Map<String, Object> getClaims() {
            return claims;
        }
    }
}
